// UrlRewriter - A .NET URL Rewriter module
// Version 1.7
//
// Copyright 2006 Intelligencia
// Copyright 2006 Seth Yates
// 

using System;

namespace Intelligencia.UrlRewriter.Actions
{
	/// <summary>
	/// Action that adds a given header.
	/// </summary>
	public class AddHeaderAction : IRewriteAction
	{
		/// <summary>
		/// Default constructor.
		/// </summary>
		/// <param name="header">The header name.</param>
		/// <param name="value">The header value.</param>
		public AddHeaderAction(string header, string value)
		{
			_header = header;
			_value = value;
		}

		/// <summary>
		/// The header name.
		/// </summary>
		public string Header
		{
			get
			{
				return _header;
			}
			set
			{
				_header = value;
			}
		}

		/// <summary>
		/// The header value.
		/// </summary>
		public string Value
		{
			get
			{
				return _value;
			}
			set
			{
				_value = value;
			}
		}

		/// <summary>
		/// Executes the action.
		/// </summary>
		/// <param name="context">The rewrite context.</param>
		public void Execute(RewriteContext context)
		{
			context.Headers.Add(Header, Value);
		}

		/// <summary>
		/// The Processing directive.
		/// </summary>
		public RewriteProcessing Processing
		{
			get
			{
				return RewriteProcessing.ContinueProcessing;
			}
		}

		private string _header;
		private string _value;
	}
}
